package com.example.saiaadmin.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.saiaadmin.entry.EbSystemDictType;
import com.example.saiaadmin.entry.EbSystemUploadfile;
import com.example.saiaadmin.service.EbSystemUploadfileService;
import com.example.saiaadmin.utils.PageBean;
import com.example.saiaadmin.utils.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 上传文件信息表Controller
 *
 *  @author  Vagrant
 * @since 2025/01/13
 */
@RestController
@RequestMapping("/eb-system-uploadfile")
public class EbSystemUploadfileController {
    @Autowired
    private EbSystemUploadfileService service;

    /**
     * 分页查询附件
     * @param page
     * @param limit
     * @param origin_name
     * @param mime_type
     * @param storage_mode
     * @return
     */
    @GetMapping("/index")
    public ResultData<PageBean<EbSystemUploadfile>> index(Integer page, Integer limit, String origin_name, String mime_type,Integer storage_mode){
        Page<EbSystemUploadfile> pageInfo = new Page<>(page,limit);
        LambdaQueryWrapper<EbSystemUploadfile> queryWrapper =new LambdaQueryWrapper<>();
        queryWrapper.eq(null != origin_name,EbSystemUploadfile::getObjectName,origin_name);
        queryWrapper.eq(null != mime_type,EbSystemUploadfile::getMimeType,mime_type);
        queryWrapper.eq(null != storage_mode,EbSystemUploadfile::getStorageMode,storage_mode);
        service.page(pageInfo,queryWrapper);
        PageBean<EbSystemUploadfile> pageBean = new PageBean<>();
        pageBean.setTotal(pageInfo.getTotal());
        pageBean.setData(pageInfo.getRecords());
        pageBean.setPer_page((int) pageInfo.getSize());
        pageBean.setLast_page((int) pageInfo.getPages());
        return ResultData.success("获取成功", pageBean);
    }
}
